<?php

namespace app\common\model\product\team;

use think\Model;

class Business extends Model
{
    // 拼团人员名单表
    protected $name = 'team_order_business';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'int';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;

    protected $append = [
        'createtime_text'
    ];

    public function getCreatetimeTextAttr($value, $data)
    {
        $createtime = isset($data['createtime']) ? trim($data['createtime']) : "";

        if (empty($createtime)) {
            return '暂无参团时间';
        }

        return date("Y-m-d", $createtime);
    }

    public function businesss()
    {
        return $this->belongsTo('app\common\model\business\Business', 'busid', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
